package cc.wfu.trigger.http;

import cc.wfu.domain.product.model.aggregate.ProductPageAggregate;
import cc.wfu.domain.product.service.IProductService;
import cc.wfu.domain.product.service.ProductService;
import cc.wfu.feign.client.OrderFeignClient;
import cc.wfu.trigger.api.dto.QueryProductsRequest;
import cc.wfu.types.enums.ProductPriceSort;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author: jia-qiang ljq1024.cc
 * @desc: ProductController 的支持类
 * @Date: 2024-05-24-19:27
 */
@Component
public class ProductControllerSupport {

    @Resource
    protected IProductService productService;

    @Resource
    protected OrderFeignClient orderFeignClient;

    /**
     * 构建 查询商品 请求参数 - 解耦
     * @param request - web 参数
     */
    protected ProductPageAggregate buildProductPageAggregate(QueryProductsRequest request) {
        return ProductPageAggregate.builder()
                .productType(request.getProductType())
                .pageNum(request.getPageNum())
                .pageSize(request.getPageSize())
                .sort(ProductPriceSort.getSortChannel(request.getProductType()))
                .build();
    }

}
